let arr = ['2', '7', '3', '0']
let result = []
arr.forEach((item1, index) => {
  let newArr = JSON.parse(JSON.stringify(arr))
  let a = +newArr.splice(index, 1)[0]
  newArr.forEach((item2, index2) => {
    let newArr2 = JSON.parse(JSON.stringify(newArr))
    let b = +newArr2.splice(index2, 1)[0]
    newArr2.forEach((item3) => {
      if (a === b + 2 * item3) {
        result.push(a + ' ' + b + ' ' + item3)
      } else if (a === item3 + 2 * b) {
        result.push(a + ' ' + item3 + ' ' + b)
      } else if (b === a + 2 * item3) {
        result.push(b + ' ' + a + ' ' + item3)
      } else if (b === item3 + 2 * a) {
        result.push(b + ' ' + item3 + ' ' + a)
      } else if (item3 === a + 2 * b) {
        result.push(item3 + ' ' + a + ' ' + b)
      } else if (item3 === b + 2 * a) {
        result.push(item3 + ' ' + b + ' ' + a)
      }
    })
  })
})

// result = [...new Set(result)]
console.log(result)

if (result.length) {
  result.forEach((item) => {
    console.log(item)
  })
} else {
  console.log(0)
}

// 四则运算
// 最大公约数
var dfs = function (arr, n, level, cur, res) {
  if (level === n) {
    res.push(cur)
  } else {
    for (let i = level; i < arr.length; i++) {
      dfs(arr, n, level + 1, [...cur, arr[i]], res)
    }
  }
}

var acc = function (arr, n) {
  let result = []
  dfs(arr, n, 0, [], result)
  return result
}

let r = acc([2, 7, 3, 0], 3)

console.log(r)
